package logic

import (
	"context"
	"teatch/model/mysql"

	"teatch/teacherrpc/internal/svc"
	"teatch/teacherrpc/teacherrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CollectAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCollectAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CollectAddLogic {
	return &CollectAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 课程收藏
func (l *CollectAddLogic) CollectAdd(in *teacherrpc.CollectAddRequest) (*teacherrpc.CollectAddResponse, error) {
	// todo: add your logic here and delete this line

	data := mysql.Collect{
		UserId:   uint(in.UserId),
		CourseId: int(in.CourseId),
		Courses:  in.Courses,
	}
	mysql.DB.Create(&data)
	return &teacherrpc.CollectAddResponse{
		CollectId: int64(data.ID),
	}, nil
}
